// 数组字符串编号 fn(['ab', 'c', 'd', 'ab', 'c']) => ['ab1', 'c1', 'd', 'ab2', 'c2']
function changeArr(arr) {
  let obj = {}
  let tmp = []
  for (let i = 0; i < arr.length; i++) {
    let keys = [];
    keys = Object.keys(obj)
    if (keys.includes(arr[i])) {
      if (obj[arr[i]].count === 1) {
        let index = tmp.findIndex(e => {
          return e === arr[i]
        })
        tmp[index] = `${arr[i]}${obj[arr[i]].count}`
      }
      obj[arr[i]].count += 1
      tmp.push(`${arr[i]}${obj[arr[i]].count}`)
    } else {
      obj[arr[i]] = {}
      obj[arr[i]].count = 1
      tmp.push(arr[i])
    }
  }
  return tmp;
}

let res = changeArr(['a', 'aaa', 'bb', 'aaa', 'ccc', 'bb', 'aaa']);
console.log(res)